package com.ques.utils;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.HashMap;
import java.util.Map;

/**
 * 返回状态信息
 *
 * @author zq  2020-01-05
 */
@Getter
@Setter
@ToString
public class BasicMessage {
    // 状态
    private int status;
    private Map<String, Object> message;

    private BasicMessage() {
    }

    public static BasicMessage success() {
        BasicMessage basicMessage = new BasicMessage();
        basicMessage.setStatus(0);
        return basicMessage;
    }

    public static BasicMessage fail() {
        BasicMessage basicMessage = new BasicMessage();
        basicMessage.setStatus(1);
        return basicMessage;
    }

    public BasicMessage putmessage(String key, Object message) {
        if (this.message == null) {
            this.message = new HashMap<>(2);
        }
        this.message.put(key, message);
        return this;
    }
}
